package cn.edu.neusoft.wuguangsheng.market.activity;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import cn.edu.neusoft.wuguangsheng.market.R;
import cn.edu.neusoft.wuguangsheng.market.bean.RegisterBean;
import cn.edu.neusoft.wuguangsheng.market.listener.TListener;
import cn.edu.neusoft.wuguangsheng.market.model.SetPasswordModel;

public class SetPasswordActivity extends BaseActivity {
    String password;
    ImageView ps_ret;
    EditText ps_password;
    Button ps_submit;
    @Override
    void initView() {
        setLayout_file(R.layout.activity_set_password);
        ps_ret=(ImageView)findViewById(R.id.ps_ret);
        ps_password=(EditText)findViewById(R.id.ps_password);
        ps_submit=(Button)findViewById(R.id.ps_submit);
    }

    @Override
    void initEvent() {
ps_submit.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        String uid=getid();
        String userpass=ps_password.getText().toString();
        if(userpass.equals("")){
            Toast.makeText(SetPasswordActivity.this,"输入密码不能为空",Toast.LENGTH_SHORT).show();
        }
        else{
            SetPasswordModel setPasswordModel=new SetPasswordModel();
            setPasswordModel.setPaaword(uid,userpass,tListener);
        }

    }
});
        ps_ret.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    void initDate() {

    }
    TListener<RegisterBean> tListener=new TListener<RegisterBean>() {
        @Override
        public void onResponse(RegisterBean registerBean) {
            String success=registerBean.getSuccess();
            if(success.equals("1")){
                Toast.makeText(SetPasswordActivity.this,"修改密码成功,请重新登陆",Toast.LENGTH_SHORT).show();
                Intent intentp=new Intent(SetPasswordActivity.this,LoginActivity.class);
                startActivity(intentp);
            }
            else{
                Toast.makeText(SetPasswordActivity.this,"修改密码失败或尝试修改其他新密码",Toast.LENGTH_SHORT).show();
            }
        }

        @Override
        public void onFail(String msg) {

        }
    };
}
